package site.lianwu.mybatis.plus.query.model;

import site.lianwu.mybatis.plus.query.QueryOption;
import site.lianwu.mybatis.plus.query.define.Condition;
import site.lianwu.mybatis.plus.query.define.Logic;
import site.lianwu.mybatis.plus.query.processor.QueryClassProcessor;
import site.lianwu.mybatis.plus.query.processor.QueryFieldProcessor;
import site.lianwu.mybatis.plus.query.processor.QueryWrapperProcessor;

/**
 * 可执行的查询语句，是对通过值验证的{@link PreparedQueryStatement}的进一步提取，用于构建{@code QueryWrapper}
 * <br>
 * 该类封装了查询语句的构建信息，包括分组、（分组内的）逻辑操作、列名、查询条件以及条件值
 *
 * @author LianWu
 * @see QueryWrapperProcessor#parse(Object, boolean, QueryOption)
 * @see QueryClassProcessor#parse(QueryClass, Object)
 * @see QueryFieldProcessor#parse(QueryField, Object)
 */
public class ExecutableQueryStatement {

    /**
     * 所属分组
     */
    private final String group;

    /**
     * 逻辑操作符，定义该查询条件在分组内与其他条件的逻辑连接关系
     */
    private final Logic logic;

    /**
     * （数据表中的）列名
     */
    private final String column;

    /**
     * 查询条件
     */
    private final Condition condition;

    /**
     * 条件值
     */
    private final Object value;

    public ExecutableQueryStatement(String group, Logic logic, String column, Condition condition, Object value) {
        this.group = group;
        this.logic = logic;
        this.column = column;
        this.condition = condition;
        this.value = value;
    }

    public String getGroup() {
        return group;
    }

    public Logic getLogic() {
        return logic;
    }

    public String getColumn() {
        return column;
    }

    public Condition getCondition() {
        return condition;
    }

    public Object getValue() {
        return value;
    }

}
